package com.ggshily.game.model.ms3d
{
	import flash.utils.ByteArray;
	
	public class Ms3d_triangle
	{
		public var flags : int;                            // word
		public var vertexIndices : Array = [0, 0, 0];         // word[3]
		public var vertexNormals : Array = [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]]; // float[3][3]
		public var s : Array = [0.0, 0.0, 0.0];
		public var t : Array = [0.0, 0.0, 0.0];
		public var smotthingGroup : int;                      // (byte)
		public var groupIndex : int;                          // (byte)
		
		public function Ms3d_triangle(bytes : ByteArray = null)
		{
			if(bytes)
			{
				flags = bytes.readShort();
				vertexIndices[0] = bytes.readShort();
				vertexIndices[1] = bytes.readShort();
				vertexIndices[2] = bytes.readShort();
				for(var i : int = 0; i < 3; i++)
				{
					for(var j : int = 0; j < 3; j++)
					{
						vertexNormals[i][j] = bytes.readFloat();
					}
				}
				s[0] = bytes.readFloat();
				s[1] = bytes.readFloat();
				s[2] = bytes.readFloat();
				t[0] = 1 - bytes.readFloat();
				t[1] = 1 - bytes.readFloat();
				t[2] = 1 - bytes.readFloat();
				smotthingGroup = bytes.readUnsignedByte();
				groupIndex = bytes.readUnsignedByte();
			}
		}
	}
}